// Copyright 2011 Jefferson Willian
// willmont7@gmail.com

#include <cstdio>

int main() {
  int n;
  int temp;
  int in;
  int games = 1;
  char names[2][50];

  while (scanf("%d", &n) && n != 0) {
    scanf("%s%s", names[0], names[1]);

    printf("Teste %d\n", games++);

    for (int i = 0;i < n;i++) {
      temp = 0;
      scanf("%d", &in);
      temp += in;
      scanf("%d", &in);
      temp += in;
      if (temp%2)
        printf("%s\n", names[1]);
      else
        printf("%s\n", names[0]);
    }

    printf("\n");
  }

  return 0;
}
